package com.lxh.updateprefixcode;

import java.util.Calendar;
import java.util.Date;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;

public class MainActivity extends Activity {
	public TextView outputText;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);		
		setContentView(R.layout.activity_main);
		outputText = (TextView) findViewById(R.id.textView1);		
		Date currentDate = getZeroTimeDate(new Date());
		
		Date expireDate = new Date(R.string.expire_date);
		expireDate = getZeroTimeDate(expireDate);
		
		//---- Test -- Go to Manual View -------//
		Intent intent = new Intent(getApplicationContext(), CustomUpdateActivity.class);
		startActivity(intent);
		
//		if (currentDate.getTime() < expireDate.getTime()) {
//			//---- Alert to user: 
//			//---- Test -- Go to Manual View -------//
//			Intent intent = new Intent(getApplicationContext(), CustomUpdateActivity.class);
//			startActivity(intent);
//			
//		} else {
//			
//			fetchContacts();
//		}
	}
	
	private Date getZeroTimeDate(Date fecha) {
	    Date res = fecha;
	    Calendar calendar = Calendar.getInstance();

	    calendar.setTime( fecha );
	    calendar.set(Calendar.HOUR_OF_DAY, 0);
	    calendar.set(Calendar.MINUTE, 0);
	    calendar.set(Calendar.SECOND, 0);
	    calendar.set(Calendar.MILLISECOND, 0);

	    res = calendar.getTime();

	    return res;
	}

	

}